from django import template
register = template.Library()
from django.utils.html import format_html
@register.simple_tag()
def circle_page(curr_page,loop_page):
    offset=abs(curr_page-loop_page)
    if offset < 3:
        if curr_page == loop_page:
            page_ele='<li class="active"><a  href="/question/?page=%s">%s</a></li>'%(loop_page,loop_page)
        else:
            page_ele = '<li><a  href="/question/?page=%s">%s</a></li>'%(loop_page,loop_page)
        return format_html(page_ele)
    else:
        return ''
@register.simple_tag()
def circle2_page(curr_page,id,id2,find_content,loop_page):
    offset=abs(curr_page-loop_page)
    if offset < 3:
        if find_content:
            if curr_page == loop_page:
                page_ele='<li class="active"><a  href="/question/?page=%s&find_content=%s">%s</a></li>'%(loop_page,find_content,loop_page)
            else:
                page_ele = '<li><a  href="/question/?page=%s&find_content=%s">%s</a></li>'%(loop_page,find_content,loop_page)
            return format_html(page_ele)
        elif id:
            if curr_page == loop_page:
                page_ele='<li class="active"><a  href="/question/?page=%s&id=%d">%s</a></li>'%(loop_page,id,loop_page)
            else:
                page_ele = '<li><a  href="/question/?page=%s&id=%d">%s</a></li>'%(loop_page,id,loop_page)
            return format_html(page_ele)
        elif id2:
            if curr_page == loop_page:
                page_ele='<li class="active"><a  href="/question/?page=%s&id2=%d">%s</a></li>'%(loop_page,id2,loop_page)
            else:
                page_ele = '<li><a  href="/question/?page=%s&id2=%d">%s</a></li>'%(loop_page,id2,loop_page)
            return format_html(page_ele)
        elif id and id2:
            if curr_page == loop_page:
                page_ele='<li class="active"><a  href="/question/?page=%s&id=%d&id2=%d">%s</a></li>'%(loop_page,id,id2,loop_page)
            else:
                page_ele = '<li><a  href="/question/?page=%s&id=%d&id2=%d">%s</a></li>'%(loop_page,id,id2,loop_page)
            return format_html(page_ele)
    else:
        return ''